package com.wxw.BaseLibrary.component;

import android.content.Context;
import android.graphics.Color;
import android.util.TypedValue;
import android.widget.AbsListView;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.wxw.BaseLibrary.drawable.LayoutParamTool;
import com.wxw.BaseLibrary.drawable.PanelStyle;

/**
 * Created by david on 2014-07-09.
 */
public class SpinnerDropDownView extends LinearLayout {
    private TextView textView;

    protected int[] backColor = new int[]{ Color.parseColor("#ffffff") };
    protected int borderColor = Color.parseColor("#c7c7c7");
    protected int borderWidth = 1;
    protected int cornerRadius = 0;
    protected int textSize = 24;
    protected int textColor = Color.BLACK;

    public SpinnerDropDownView(Context context) {
        super(context);
        setBackground(PanelStyle.createPanelStyle(null, backColor, borderWidth, borderColor, cornerRadius));
        FrameLayout.LayoutParams layoutParams1 = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
                FrameLayout.LayoutParams.WRAP_CONTENT);
        layoutParams1.setMargins(5,5,5,5);
        AbsListView.LayoutParams layoutParams2 = new AbsListView.LayoutParams(layoutParams1);
        setLayoutParams(layoutParams2);
        textView = new TextView(context);
        LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        layoutParams.setMargins(5, 10, 5, 10);
        layoutParams.weight = 1;
        textView.setBackgroundColor(Color.TRANSPARENT);
        textView.setTextColor(Color.BLACK);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
        addView(textView, layoutParams);
    }

    public TextView getTextView() {
        return textView;
    }

    public int[] getBackColor() {
        return backColor;
    }

    public void setBackColor(int[] backColor) {
        this.backColor = backColor;
    }

    public int getBorderColor() {
        return borderColor;
    }

    public void setBorderColor(int borderColor) {
        this.borderColor = borderColor;
    }

    public int getBorderWidth() {
        return borderWidth;
    }

    public void setBorderWidth(int borderWidth) {
        this.borderWidth = borderWidth;
    }

    public int getCornerRadius() {
        return cornerRadius;
    }

    public void setCornerRadius(int cornerRadius) {
        this.cornerRadius = cornerRadius;
    }

    public int getTextSize() {
        return textSize;
    }

    public void setTextSize(int textSize) {
        this.textSize = textSize;
        textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    }

    public int getTextColor() {
        return textColor;
    }

    public void setTextColor(int textColor) {
        this.textColor = textColor;
        textView.setTextColor(textColor);
    }

    public void refreshView(){
        setBackground(PanelStyle.createPanelStyle(null, backColor, borderWidth, borderColor, cornerRadius));
    }
}
